<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\models\Employee;
use app\services\JsonService;
use app\services\UtilService as Util;
use cmf\controller\AdminBaseController;
use think\Db;

class EmployeeController extends AdminBaseController
{
    function index(){
        return $this->fetch();
    }

    //获取工资数据
    public function employee_data()
    {
        $page   = $this->request->param('page','1');
        $limit  = $this->request->param('limit','10');
        $model  = new Employee();
        $res    = $model->getListById($page,$limit);
        $count  = $model->count('id');
        if($res){
            JsonService::successlayui($count,$res,'数据列表');
        }else{
            JsonService::fail(Employee::getErrorInfo());
        }
    }

    public function employee_add()
    {
        $data = Util::postMore([
            ['id', 0],
            'employee_id',
            'wage',
            'wages_paid',
            'wages_basic',
            'bonus',
            ['is_full',0],
            'full_attendance'
        ]);
        $data['employee_id'] = 1;
        if($data['id']){

        }else{

        }
    }


    public function get_select_list()
    {
        $keyword        = $this->request->param('keyword','');
        $employee_model = new Employee();
        $data   = $employee_model->getList($keyword);
        $count  = $employee_model->getCount($keyword);
        return json([
            'code'      =>0,
            'count'     =>$count,
            'message'   =>'员工列表',
            'data'      =>$data
        ]);
    }

}
